package com.lingnan.wanxiangxinxun.task;


import com.lingnan.wanxiangxinxun.service.ITempFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Slf4j
public class CleanTempFileTask {

    @Autowired
    private ITempFileService tempFileService;

    //@Scheduled(cron = "*/10 * * * * ?") // 每10秒触发(测试用)
    @Scheduled(cron = "0 0 23 * * ?") // 每天23点执行 TODO:清理的时候加锁，不允许用户新增或者修改新闻
    public void cleanExpiredData() {
        log.info(" 【定时任务】执行清理: {}" ,LocalDateTime.now());
        tempFileService.removeAllTempFile();
    }

}
